	/**
    *******图片播放插件*******
	*  id         who
	*  autoPlay   是否自动播放 默认true
	*  isCursor   是否显示又不 默认true
	*  move       是否显示前进后退 默认true
	*  time       播放速度 默认3000
	*  adaptor    是否自适应
	*  data       图片信息 json 格式 [{"id":"","name":"","url":"","src","other":""},...]
    */
   $.fn.slidePic = function(options){
	   var defaults = {
		   id :"",
		   autoPlay : true,
		   isCursor : true,
		   move : true,
		   time : 3000,
		   data : [],
		   number : 1,
		   adaptor: false
	   };
	   var opts = $.extend(defaults,options);
	   var id = opts.id;
	   var id_ul = id + "_ul";
	   var autoPlay = opts.autoPlay;
	   var isCursor = opts.isCursor;
	   var move  = opts.move;
	   var time = opts.time;
	   var data = opts.data;
	   var number = opts.number;
	   var adpator = opts.adpator;
	   var obj = $("#"+id);
	   var width = obj.width();
	   var height = obj.height();
	   var size = data.length;
	   var ul , li;
	   var index = 1;
	   var cursor = 1;
	   var timeclear;
	   var flag = true;
	   var prev , next;
	   createHtml();
	   init();
	   
	   //创建图片
	   function createHtml(){
		   	if(size == 0) {
		   		ul = $(obj[0].getElementsByTagName("ul"));
		   		ul.attr("id", id_ul);
		   		size = ul.children("li").length;
		   		if(size > 1) {
		   			var head = ul.children("li:lt("+number+")").clone();
		   			var tail = ul.children("li:gt("+(size - number - 1)+")").clone();
		   			ul.prepend(tail);
		   			ul.append(head);
		   		}
		   	} else {
		   		var div = [];
		   		var i,j;
		   		div.push("<div class=\"slide-common\">");
		   		div.push("<ul id="+id_ul+">");
		   		div.push("<li><a href=\""+data[size-1].href+"\" target=\"_blank\"><img src='"+data[size-1].image+"' width=\"100%\" height=\"100%\"/></a><div class='ad-name'><b>"+data[size-1].name+"</b></div></li>");
		   		for(i = 0; i < size; i++){
		   			var item = data[i];
		   			div.push("<li><a href=\""+data[size-1].href+"\" target=\"_blank\"><img  src=\""+item.image+"\" width=\"100%\" height=\"100%\"/></a><div class='ad-name'><b>"+item.name+"</b></div></li>");
		   		}
		   		div.push("<li><a href=\""+data[size-1].href+"\" target=\"_blank\"><img src =  '"+item.image+"' width=\"100%\" height=\"100%\"/></a><div class='ad-name'><b>"+item.name+"</b></div></li>");
		   		div.push("</ul>");
		   		div.push("</div>");	
		   		obj.append(div.join(""));
		   		ul = $(obj[0].getElementsByTagName("ul"));
		   	}
			
			var bars = [];
			bars.push("<div class=\"slide-cursor\">");
    	    for(j = 0; j < size; j++){
				if(j == 0){
					bars.push("<b class=\"b-selected\"></b>");
				}else{
					bars.push("<b></b>");
				}
				
			}
    	    bars.push("</div>");
    	    bars.push("<span class=\"slide-prev\"><i></i></span>");
    	    bars.push("<span class=\"slide-next\"><i></i></span>");
			var slider_common = obj.children(".slide-common");
			slider_common.append(bars.join(""));
			if(adpator) {
				var screen =  window.screen.availWidth;
				if(screen <= 1366) {
					var images = ul.find("img");
					for(j = 0; j < images.length; j++) {
						var $image = $(images[j]);
						var src = $image.attr("src");
						src = src.substring(0, src.lastIndexOf(".")) + "_1366" + src.substring(src.lastIndexOf("."), src.length);
						$image.attr("src", src)
					}
				}
			}
			
	   };
	   //初始化
	  function init(){
		  //obj.eq(0).children("ul");  //getElementById ...
		 li = ul.children("li");
		 li.width(width);
		 li.height(height);
		 prev = ul.siblings(".slide-prev");
		 next = ul.siblings(".slide-next");
		 if(!move){
		 	prev.css("display","none");
			next.css("display","none");
		 }
		 prev.css("top",(height/2-40)+"px");
		 next.css("top",(height/2-40)+"px");
		 if(!isCursor){
		 	ul.next(".slide-cursor").css("display","none");
		 }
		 if(size == 1){
			return false;
		 }
		 ul.width((size + 2) * width);
		 ul.height(height);
		 ul.css("left",-width+"px");
		 hrEvent();
	  };
	  //横向事件
	  function hrEvent(){	
		if(autoPlay){
			play();
		}
		function play(){
			//自动播放
			obj.on("mouseleave",function(){
				timeclear = window.setInterval(function(){
					index++;
					if(index > size){
						ul.css("left",width*(0));
						index =  1;
					}
					cursor = index;
					ul.next(".slide-cursor").children("b").eq(cursor-1).addClass("b-selected").siblings().removeClass("b-selected");
					slideHr(-index);
				},time);
			}).on("mouseenter",function(){
				window.clearInterval(timeclear);
				prev.stop().animate({
					left: 0
				});
				next.stop().animate({
					right: 0
				});
			}).trigger("mouseleave");
		};
		obj.on("mouseleave",function(){
			prev.stop().animate({
				left: -45
			});
			next.stop().animate({
				right: -45
			});
		}).on("mouseenter",function(){
			prev.stop().animate({
				left: 0
			});
			next.stop().animate({
				right: 0
			});
		});
		//滑动
		function slideHr(index){
			//var flag = ul.is(":animated");
			ul.stop().animate({
				left: index * width 
			},function(){
				flag = true;
			});
		}
		//点击向左
		$("#"+id_ul+"~.slide-prev").on("click",function(){
			if(flag){
				flag = false;
				index--;
				if(index < 0){
					ul.css("left",-width*(size));
					index = size - 1;
				}
				//console.log("left:   "+index);
				cursor = index;
				ul.next(".slide-cursor").children("b").eq(cursor-1).addClass("b-selected").siblings().removeClass("b-selected");
				slideHr(-index);
		    }
		});
		//点击向右
		$("#"+id_ul+"~.slide-next").on("click",function(){
			if(flag){
				flag = false;
				index++;
				if(index > size){
					ul.css("left",width*(0));
					index =  1;
				}
				//console.log("right:   "+index);
				cursor = index;
				ul.next(".slide-cursor").children("b").eq(cursor-1).addClass("b-selected").siblings().removeClass("b-selected");
				slideHr(-index);
			}
		});
		//点击游标
		$("#"+id_ul+"+.slide-cursor").children("b").on("click",function(){
			index = $(this).index() + 1;
			ul.next(".slide-cursor").children("b").eq(index-1).addClass("b-selected").siblings().removeClass("b-selected");
			slideHr(-index);
		});
	  };
   };